package com.ruoyi.lm.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lm.domain.LmShow;
import com.ruoyi.lm.service.ILmShowService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 是否显示统计数据Controller
 * 
 * @author ruoyi
 * @date 2020-09-21
 */
@Controller
@RequestMapping("/lm/show")
public class LmShowController extends BaseController
{
    private String prefix = "lm/show";

    @Autowired
    private ILmShowService lmShowService;

    @RequiresPermissions("lm:show:view")
    @GetMapping()
    public String show()
    {
        return prefix + "/show";
    }

    /**
     * 查询是否显示统计数据列表
     */
    @RequiresPermissions("lm:show:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(LmShow lmShow)
    {
        startPage();
        List<LmShow> list = lmShowService.selectLmShowList(lmShow);
        return getDataTable(list);
    }

    /**
     * 导出是否显示统计数据列表
     */
    @RequiresPermissions("lm:show:export")
    @Log(title = "是否显示统计数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(LmShow lmShow)
    {
        List<LmShow> list = lmShowService.selectLmShowList(lmShow);
        ExcelUtil<LmShow> util = new ExcelUtil<LmShow>(LmShow.class);
        return util.exportExcel(list, "show");
    }

    /**
     * 新增是否显示统计数据
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存是否显示统计数据
     */
    @RequiresPermissions("lm:show:add")
    @Log(title = "是否显示统计数据", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(LmShow lmShow)
    {
        return toAjax(lmShowService.insertLmShow(lmShow));
    }

    /**
     * 修改是否显示统计数据
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        LmShow lmShow = lmShowService.selectLmShowById(id);
        mmap.put("lmShow", lmShow);
        return prefix + "/edit";
    }

    /**
     * 修改保存是否显示统计数据
     */
    @RequiresPermissions("lm:show:edit")
    @Log(title = "是否显示统计数据", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(LmShow lmShow)
    {
        return toAjax(lmShowService.updateLmShow(lmShow));
    }

    /**
     * 删除是否显示统计数据
     */
    @RequiresPermissions("lm:show:remove")
    @Log(title = "是否显示统计数据", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(lmShowService.deleteLmShowByIds(ids));
    }
}
